#include<bits/stdc++.h>

using namespace std;
int n,L,R;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&L,&R);
	if(R-L>=n||R%n-L%n!=R-L)printf("%d\n",n-1);
	else printf("%d\n",R%n);
	return 0;
}
